using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableStoryQuestDao:DaoBase<TableStoryQuest>
    {
        public override void AddPrimaryIndex(TableStoryQuest model)
        {
            cachePrimary[model.questId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableStoryQuest.txt";
        }

        protected override TableStoryQuest ParseRowData(string[] rowData)
        {
            TableStoryQuest data = new TableStoryQuest();
			data.questId = rowData [0];
			data.name = rowData [1];
			data.desc = rowData [2];

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.order = 0;
            }
            else
            {
                data.order = int.Parse(rowData[3]);
            }
			data.npcId = rowData [4];

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.type = 0;
            }
            else
            {
                data.type = int.Parse(rowData[5]);
            }
			data.missionId = rowData [6];

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.forceMain = 0;
            }
            else
            {
                data.forceMain = int.Parse(rowData[7]);
            }
			data.rewards = rowData [8];

            return data;
        }


        public override void AddOneIndex(TableStoryQuest model)
        {
            if (!cacheOneIndex.ContainsKey(model.missionId.ToString()))
            {
                cacheOneIndex[model.missionId.ToString()] = new List<TableStoryQuest>();
            }
            cacheOneIndex[model.missionId.ToString()].Add(model);
        }
    

    }

}
